#include "conn.hpp"

int main(){
    StringUtil::UrlParam params;
    MYSQL* conn;
    Init(params,conn); 

    //根据业务需要进行计算
    string newname = params["newname"];
    string user = params["user"];
    string pwd = params["pwd"];
    stringstream ss;
    string output;

    if(newname == ""){
        //是改密码
        OperateUser::ModifyUser(conn,user,"pwd",pwd);
        Stay(conn,output,params,user);
    }else{
        //改用户名
        OperateUser::ModifyUser(conn,user,"name",newname);
        Stay(conn,output,params,newname);
    }
    
    cout << "Set-Cookie: user=" << newname << ";\n";

    ss << output;
    HttpResponse(ss.str());
    return 0;
}
